//
//  LCGouponCollectionViewCell.m
//  lechuang
//
//  Created by Mr_hi on 2023/3/21.
//  Copyright © 2023 Mooyi. All rights reserved.
//

#import "LCGouponCollectionViewCell.h"
#import "LCStudyModel.h"
#import "LCTaoKeGoodsModel.h"

@interface LCGouponCollectionViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *strthumbView;

@property (weak, nonatomic) IBOutlet UILabel *strtitleLb;

@property (weak, nonatomic) IBOutlet UILabel *priceLb;

@property (weak, nonatomic) IBOutlet UIView *couponView;

@property (weak, nonatomic) IBOutlet UILabel *voucherLb;

@property (weak, nonatomic) IBOutlet UILabel *oldPriceLb;

@property (weak, nonatomic) IBOutlet UIView *oldPriceLine;

@end

@implementation LCGouponCollectionViewCell

-(void)setItem:(LCTaoKeGoodsModel *)item {
    _item = item;
    
    NSString * thumbStr = kFORMAT(@"http:%@",item.pict_url);
    [self.strthumbView sd_setImageWithURL:[NSURL URLWithString:thumbStr]];
    self.strtitleLb.text = item.title;
    self.priceLb.text = kFORMAT(@"%@",item.zk_final_price);
    self.couponView.hidden = YES;
    self.oldPriceLb.text = @"";
    self.oldPriceLine.hidden = YES;
    if (item.coupon_info.length) {
        self.couponView.hidden = NO;
        self.oldPriceLine.hidden = NO;
        self.voucherLb.text = kFORMAT(@"%@",item.coupon_info);
        NSDecimalNumber * zfPrice = [NSDecimalNumber decimalNumberWithString:item.zk_final_price];
        NSDecimalNumber * couponPrice = [NSDecimalNumber decimalNumberWithString:item.coupon_amount];
        NSDecimalNumberHandler *handler = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain scale:2 raiseOnExactness:NO raiseOnOverflow:NO raiseOnUnderflow:NO raiseOnDivideByZero:YES];
        NSDecimalNumber *num = [zfPrice decimalNumberBySubtracting:couponPrice withBehavior:handler];
        self.priceLb.text = kFORMAT(@"%@",num);
        self.oldPriceLb.text = kFORMAT(@"¥%@",item.zk_final_price);
    }
}

@end


@interface LCCouponHeaderViewCollectionCell ()

@end

@implementation LCCouponHeaderViewCollectionCell

@end
